package cn.jsj.fixed.asset;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 修改固定资产信息处理类
 * @author LI
 *
 */
 public class ModifyAssetInfo extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
	 public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		 	// 调试信息
		  	cn.jsj.utils.SysLogger.PrintInfo("修改规定资产信息");
		    //输出流
		    java.io.PrintWriter out=response.getWriter();

		  	//新建资产信息类
		  	cn.jsj.pojo.TblFixedAssets tfa=new cn.jsj.pojo.TblFixedAssets();
		  	//赋值
		  	tfa.setBuyTime(cn.jsj.utils.TimeDispose.transferDate(request.getParameter("mAssetTime").trim()));
		  	tfa.setFixedAssetsId(Integer.parseInt(request.getParameter("mAssetId").trim()));
		  	tfa.setGoodsBrief(request.getParameter("mAssetBrief").trim());
		  	tfa.setGoodsMoney(Integer.parseInt(request.getParameter("mAssetMoney").trim()));
		  	tfa.setGoodsName(request.getParameter("mAssetName").trim());
		  	//判断输入的报销数量是否大于购买数量
		  	if(Integer.parseInt(request.getParameter("mAssetPurNumber").trim())<Integer.parseInt(request.getParameter("mAssetWipeNumb").trim())){
		  		out.println("{message:'更新失败，报销量大于购买量！'}");
		  		out.flush();
		  		out.close();
		  		return;
		  	}
		  	tfa.setPurchaseNumber(Integer.parseInt(request.getParameter("mAssetPurNumber").trim()));
		  	tfa.setWipeOutNumber(Integer.parseInt(request.getParameter("mAssetWipeNumb").trim()));

		  	//调试信息
		  	 cn.jsj.utils.SysLogger.PrintExceptionr("赋值完成！");

		  	 //更新固定资产信息
		  	  cn.jsj.dao.TblFixedAssetsDAO tfad=new cn.jsj.dao.TblFixedAssetsDAO();
		  	  int updateResult=tfad.updateFixedAsset(tfa);

		  	  //调试信息
		  	  cn.jsj.utils.SysLogger.PrintInfo("更新结果----------->"+updateResult);

		  	   //如果更新成功
		  	   if(updateResult==1){
		  		   out.println("{message:'更新成功！'}");
		  	   }else{
		  		   out.println("{message:'更新失败！'}");
		  	   }
		  	   out.flush();
		  	   out.close();
	}
}